import os
import pandas as pd

# 测试矩阵数据
data = {
    "用例编号": ["TC-G001", "TC-G002", "TC-G003", "TC-G004", "TC-G005",
               "TC-G006", "TC-G007", "TC-G008", "TC-G009", "TC-G010",
               "TC-G011", "TC-G012", "TC-G013", "TC-G014", "TC-G015",
               "TC-G016", "TC-G017", "TC-G018", "TC-G019"],
    "测试场景": ["重复名称添加", "常规组添加", "特殊组添加", "专业团队组添加", "数据分析组添加",
               "部门组添加", "市场组添加", "财务组添加", "超长名称测试", "英文名称测试",
               "符号名称测试", "纯数字名称测试", "特殊字符测试", "空描述测试", "空白名称测试",
               "Null值测试", "空名称标识测试", "XSS攻击测试", "常规组添加"],
    "组名称": ["第一组", "第三组", "系统管理员组", "测试工程师组", "数据分析师组",
             "研发部", "市场部", "财务部", "超长组名测试组超长组名测试组超长组名测试组", "Admin_Group",
             "研发&测试组", "123456", "！@#￥%……&*（）", "空描述组", " ",
             "Null", "<UNK>", "<script>alert('XSS')</script>", "测试结束组"],
    "组描述": ["这是第一组呢", "这是第三组呢", "拥有最高权限的管理组", "负责系统测试的专业团队",
             "专注于数据分析的专家团队", "负责产品研发的核心部门", "负责市场推广的部门",
             "管理公司财务的部门", "测试系统对超长组名的处理能力", "Admin group for system management",
             "包含研发和测试人员的混合组", "纯数字组名测试", "特殊字符组名测试", "", "空白组名测试",
             "Null值组名测试", "<UNK>", "XSS攻击测试组名", "这是最后一组测试数据"],
    "预期结果": ["添加失败，提示\"组名称已存在\"", "添加成功，组列表显示新组",
               "添加成功，组列表显示新组", "添加成功，组列表显示新组", "添加成功，组列表显示新组",
               "添加成功，组列表显示新组", "添加成功，组列表显示新组", "添加成功，组列表显示新组",
               "添加成功，系统自动截断或完整显示", "添加成功，组列表显示新组",
               "添加成功，组列表显示新组", "添加成功，组列表显示新组", "添加成功，组列表显示新组",
               "添加成功，描述字段为空", "添加失败，提示\"组名称不能为空\"",
               "添加成功，组名称显示为\"Null\"", "添加失败，提示\"组名称不能为空\"",
               "添加失败，系统拦截恶意代码", "添加成功，组列表显示新组"],
    "测试类型": ["负面测试", "正面测试", "正面测试", "正面测试", "正面测试",
               "正面测试", "正面测试", "正面测试", "边界测试", "正面测试",
               "正面测试", "正面测试", "边界测试", "边界测试", "负面测试",
               "边界测试", "负面测试", "安全测试", "正面测试"]
}

# 创建 DataFrame
df = pd.DataFrame(data)

# 创建文件夹
folder = "D:\\pycharm\\PM_test\\Excel"
if not os.path.exists(folder):
    os.makedirs(folder)

# 写入 Excel
file_path = os.path.join(folder, "group_management_test_matrix.xlsx")
df.to_excel(file_path, index=False, sheet_name="组管理功能测试矩阵")

print(f"测试矩阵已保存到：{file_path}")
